import 'package:ducafe_ui_core/ducafe_ui_core.dart';
import 'package:flutter/material.dart';
import 'package:flutter_mes_app/common/index.dart';
import 'package:flutter_mes_app/main.dart';
import 'package:get/get.dart';
import 'package:group_button/group_button.dart';

import 'index.dart';

class CheckboxPage extends GetView<CheckboxController> {
  const CheckboxPage({super.key});

  // 主视图
  Widget _buildView() {
    return <Widget>[
      const TextWidget.h4("试例1 控制选择"),
      GroupButton(
        isRadio: false,
        controller: controller.groupButtonexample1controller,
        buttons: const ["12:00", "13:00", "14:30", "18:00", "19:00", "21:40"],
        onSelected: (value, index, isSelected) =>
            {print('$index $value $isSelected selected')},
      ),
      ButtonWidget(
        text: 'Select 1 button',
        onTap: () => {controller.groupButtonexample1controller.selectIndex(1)},
      ),
      const TextWidget.h4("试例2"),
      GroupButton(
        isRadio: false,
        buttons: controller.options,
        
      ),
      const TextWidget.h4("column"),
      GroupButton(
        isRadio: false,
        buttons: controller.options,
        options:const GroupButtonOptions(groupingType: GroupingType.column)
        
      ),
      const TextWidget.h4("row"),
      GroupButton(
        isRadio: false,
        buttons: controller.options,
        options:const GroupButtonOptions(groupingType: GroupingType.row)
      ),
        const TextWidget.h4("wrap"),
      const GroupButton(
        isRadio: false,
        buttons: ['11111','11111','11111','11111','11111','11111'],
        options:GroupButtonOptions(groupingType: GroupingType.wrap)
      ),
    ].toColumnSpace().scrollable();
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<CheckboxController>(
      init: CheckboxController(),
      id: "checkbox",
      builder: (_) {
        return Scaffold(
          appBar: AppBar(title: const Text("checkbox")),
          body: SafeArea(
            child: _buildView(),
          ),
        );
      },
    );
  }
}
